package xyz.ddlnt.management.mg.controller;

import io.swagger.v3.oas.annotations.Operation;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;
import xyz.ddlnt.commonutil.result.Result;
import xyz.ddlnt.model.dto.TechnologyDTO;
import xyz.ddlnt.model.vo.TechnologyInfoVO;
import xyz.ddlnt.model.vo.TechnologySelectVO;
import xyz.ddlnt.model.vo.TechnologyVO;
import xyz.ddlnt.servicemgclient.client.TechnologyFeignClient;

import java.time.LocalDateTime;
import java.util.List;

/**
 * @author ZZULI_SE 210910
 * @data 2025/5/1 21:57
 */
@Slf4j
@Tag(name = "科目管理接口")
@RestController
@RequestMapping(("/technology"))
public class TechnologyController {

    @Resource
    private TechnologyFeignClient technologyFeignClient;

    @Operation(summary = "获取所有类别科目基础信息")
    @GetMapping("/selectTechCategoryInfos")
    Result<List<TechnologySelectVO>> selectTechCategoryInfos() {
        return technologyFeignClient.selectTechCategoryInfos();
    }

    @Operation(summary = "获取所有科目")
    @GetMapping("/selectAllTechnology")
    Result<List<TechnologyVO>> selectAll() {
        return technologyFeignClient.selectAll();
    }

    /**
     * 用户端接口
     * @param categoryId
     * @return
     */
    @Operation(summary = "根据类别id获取科目信息")
    @GetMapping("/selectByCategoryId/{categoryId}")
    Result<List<TechnologyInfoVO>> selectByCategoryId(@PathVariable Long categoryId) {
        return technologyFeignClient.selectByCategoryId(categoryId);
    }

    /**
     * 用户端接口
     * @param technologyId
     * @return
     */
    @Operation(summary = "根据科目id获取科目信息")
    @GetMapping("/selectByTechnologyId/{technologyId}")
    public Result<TechnologyInfoVO> selectByTechnologyId(@PathVariable Long technologyId) {
        return technologyFeignClient.selectByTechnologyId(technologyId);
    }

    @Operation(summary = "添加科目")
    @PostMapping("/addTechnology")
    Result<TechnologyVO> addTechnology(@RequestBody TechnologyDTO technologyDTO) {
        return technologyFeignClient.addTechnology(technologyDTO);
    }

    @Operation(summary = "更新科目")
    @PutMapping("/updateTechnology")
    Result<LocalDateTime> updateTechnology(@RequestBody TechnologyDTO technologyDTO) {
        return technologyFeignClient.updateTechnology(technologyDTO);
    }

    @Operation(summary = "删除科目")
    @DeleteMapping("/deleteTechnology/{id}")
    Result<Boolean> deleteTechnology(@PathVariable Long id) {
        return technologyFeignClient.deleteTechnology(id);
    }
}
